package com.caltco.cargo.ops.modules.sys.controller;

import com.caltco.cargo.ops.common.api.R2;
import com.caltco.cargo.ops.common.api.Result;
import com.caltco.cargo.ops.common.base.gen.BaseController;
import com.caltco.cargo.ops.modules.sys.entity.Comments;
import com.caltco.cargo.ops.modules.sys.request.CommentsRequest;
import com.caltco.cargo.ops.modules.sys.service.CommentsService;
import com.caltco.cargo.ops.modules.sys.vo.CommentsVO;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/comment")
@AllArgsConstructor
public class CommentsController extends BaseController<Comments, CommentsService> {

    private final CommentsService commentService;

    @PostMapping("/add")
    public Result<String> addComment(@RequestBody CommentsRequest request) {
        return commentService.addComment(request)? R2.setOkMsg("新增成功"): R2.setErrMsg("新增失败");
    }


    @PostMapping("/getList")
    public Result<List<CommentsVO>> getCommentList(@RequestBody CommentsRequest request) {
        return R2.ok(commentService.getCommentListByMomentId(request));
    }
}
